<template>
  <div class="common-wrap">
    <div class="stretchingflex">
      <div
        :class="[
          'stretchingleft',
          {
            'stretchingleftWidth-100': leftType,
            'stretchingRightWidth-0': rightType,
          },
        ]"
      >
        <div style="padding: 0 20px">
          <slot name="left"></slot>
        </div>
        <el-icon class="icon-left" size="16" @click="leftType = !leftType">
          <CaretRight v-if="!leftType" />
          <CaretLeft v-else />
        </el-icon>
      </div>
      <el-divider
        direction="vertical"
        style="height: 100%; margin: 0"
      ></el-divider>
      <div class="stretchingRight">
        <el-scrollbar>
          <div style="padding: 0 20px">
            <slot name="right"></slot>
          </div>
        </el-scrollbar>
        <el-icon class="icon-right" size="16" @click="rightType = !rightType">
          <CaretLeft v-if="!rightType" />
          <CaretRight v-else />
        </el-icon>
      </div>
    </div>
  </div>
</template>

<script setup>
import { CaretLeft } from "@element-plus/icons-vue";
import { ref } from "vue";
const leftType = ref(false);
const rightType = ref(false);
</script>

<style lang="scss" scoped>
.stretchingflex {
  display: flex;
  height: 100%;
}
.stretchingleft {
  width: 50%;
  height: 100%;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease-in-out;
}
.stretchingleftWidth-100 {
  width: 100%;
}
.stretchingRightWidth-0 {
  width: 0%;
}
.stretchingRight {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
}
.icon-left {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 0;
  height: 41px;
  width: 16px;
  background: #b3b3b38f;
  border-radius: 8px 0px 0px 8px;
  color: #fff;
  cursor: pointer;
}
.icon-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  height: 41px;
  width: 16px;
  background: #b3b3b38f;
  border-radius: 0px 8px 8px 0px;
  color: #fff;
  cursor: pointer;
}
</style>